##Process tifs using Tesseract, saves txt files to the same directory the tiffs are in
## change tif_Dir root path to the one with all the tifs to convert

new-PSDrive -name tif_DIR -PSProvider filesystem  -root(resolve-Path c:\temp\50_year)
new-PSDrive -name Tesseract -PSProvider filesystem -root(resolve-Path "C:\TEMP\tesseract-2.01")

function run-tesseract
{
    param([string] $cmd = "tesseract:\dlltest.exe", 
        [string] $sourceTif, 
        [string] $destinationTxt)
       
        $ci = (resolve-Path $cmd).ProviderPath
        $ci += " " +  $sourceTif
        $ci += " " + $destinationTxt
        $ci

        invoke-Expression $ci | out-Null   
    
}

get-ChildItem tif_DIR:\. -include *.tif -recurse | 
    foreach-Object -process { 
        $base = (resolve-Path "tif_DIR:\" ).ProviderPath
        $base += $_.Name.Remove($_.Name.Length - $_.Extension.Length)
        $st = $base + ".tif"
        $dt = $base + ".txt"
        
        run-tesseract -sourceTif $st  -destinationTxt $dt 
    }




